

// 221.最大正方形
class Solution {
public:
    int maximalSquare(vector<vector<char>>& matrix) {
        int n = matrix.size() , m = matrix[0].size() , ret = 0;
        vector<vector<int>> dp(n + 1 , vector<int>(m + 1));
        for(int i = 1; i <= n ; i++)
        {
            for(int j = 1; j <= m ; j++)
            {
                if(matrix[i - 1][j - 1] == '1')
                    dp[i][j] = min(min(dp[i - 1][j] , dp[i][j - 1]) , dp[i - 1][j - 1] ) + 1;
                ret = max(ret , dp[i][j]);
            }
        }
        return ret*ret;
    }
};